ConvertDatabaseDriver Method (Database Object)
Use ConvertDatabaseDriver to convert the database driver DLL used by the report.
Syntax
Sub ConvertDatabaseDriver (pDLLName As String, blDoImmediateConvert as Boolean)
Parameters
Parameter
| Description
|
pDllName
| Specifies the new DLL for the database driver.
|
blDoImmediateConvert
| Specifies when the database driver will be converted. If True, the database driver is converted when the report is previewed, or the when the database is verified. If False, the database driver is converted when the report is refreshed in the preview window.
|
Remarks
- Set blDoImmediate to False when you want the user to be prompted for the data source information. This applies to reports that are previewed and refreshed in the Crystal Report Viewer, and to reports that are exported or saved to a Crystal Report format (.rpt), and previewed and refreshed in the Crystal Reports Designer. When the report is previewed, a dialog box for the new data source appears. For example, converting to ODBC (P2sodbc.dll) opens the Set Data Source dialog box, while converting to OLEDB (P2soledb.dll) opens the Data Link Properties dialog box.
- Set blDoImmediateConvert to True when you want to set the data source at runtime. Additional code must be added to set the logon information for the data source, and to verify the database. One exception is converting to OLEDB (P2soledb.dll). Since there is no method to set the provider at runtime the Data Links dialog box will always prompt for the data source. In this case only the code to convert the databse driver is required.
- Once the database is converted, and the data source is set, either through code, or through a dialog box, three additional prompts may appear:
- Logon to the data source
This dialog box allows you to log on to the correct data source. If the data source is not secured, you can click OK without entering any logon information. - Verify the database
This is a message warning the user that the database file has changed and the report is being updated. - Map the fields.
This dialog box allows you to map the fields that have changed with the new data source. For more information on mapping fields see "Re-mapping altered database fields" in the Crystal Reports Online Help (Crw.chm).
Sample
The following code demonstrates how to convert the database driver to ODBC (P2sodbc.dll) using the ConverDataBaseDriver method. The ODBC data source is pointing to a Microsoft Access database.
'Instantiate the report object.
Set m_Report = New CrystalReport1
' Convert the database driver to ODBC.
m_Report.Database.ConvertDatabaseDriver "p2sodbc.dll", True
' Set the logon information for the ODBC data source.
' If the logon information is not set an error will be produced when the
' report is previewed or exported.
m_Report.Database.Tables(1).SetLogOnInfo "Xtreme Sample Database", "",
"", ""
' Verify the database.
' If the database is not verified before exporting an error will be
produced.
' If the database is not verified before previewing the report, the user
may be
' prompted when the report is refreshed in the Crystal Report Viewer.
m_Report.Database.Verify